define([
  './defaultValue-0a909f67',
  './Matrix3-b6f074fa',
  './arrayRemoveDuplicates-e9673044',
  './BoundingRectangle-826280cd',
  './Transforms-dadc538f',
  './Matrix2-163b5a1d',
  './ComponentDatatype-77274976',
  './PolylineVolumeGeometryLibrary-64eaf307',
  './GeometryAttribute-e2b38d72',
  './GeometryAttributes-f06a2792',
  './IndexDatatype-2149f06c',
  './Math-e97915da',
  './PolygonPipeline-1ccef6d7',
  './combine-ca22a614',
  './RuntimeError-06c93819',
  './WebGLConstants-a8cc3e8c',
  './EllipsoidTangentPlane-f7077c2e',
  './AxisAlignedBoundingBox-e5bb9f92',
  './IntersectionTests-1307e0a8',
  './Plane-1c5a21a3',
  './PolylinePipeline-2b44aa86',
  './EllipsoidGeodesic-b00a0416',
  './EllipsoidRhumbLine-7f84cca0'
], function (e, t, i, n, o, a, l, r, s, p, c, d, u, y, f, g, h, m, E, P, _, b, k) {
  'use strict'
  function C(i) {
    const n = (i = e.defaultValue(i, e.defaultValue.EMPTY_OBJECT)).polylinePositions,
      o = i.shapePositions
    ;(this._positions = n),
      (this._shape = o),
      (this._ellipsoid = t.Ellipsoid.clone(e.defaultValue(i.ellipsoid, t.Ellipsoid.WGS84))),
      (this._cornerType = e.defaultValue(i.cornerType, r.CornerType.ROUNDED)),
      (this._granularity = e.defaultValue(i.granularity, d.CesiumMath.RADIANS_PER_DEGREE)),
      (this._workerName = 'createPolylineVolumeOutlineGeometry')
    let l = 1 + n.length * t.Cartesian3.packedLength
    ;(l += 1 + o.length * a.Cartesian2.packedLength), (this.packedLength = l + t.Ellipsoid.packedLength + 2)
  }
  C.pack = function (i, n, o) {
    let l
    o = e.defaultValue(o, 0)
    const r = i._positions
    let s = r.length
    for (n[o++] = s, l = 0; l < s; ++l, o += t.Cartesian3.packedLength) t.Cartesian3.pack(r[l], n, o)
    const p = i._shape
    for (s = p.length, n[o++] = s, l = 0; l < s; ++l, o += a.Cartesian2.packedLength) a.Cartesian2.pack(p[l], n, o)
    return t.Ellipsoid.pack(i._ellipsoid, n, o), (o += t.Ellipsoid.packedLength), (n[o++] = i._cornerType), (n[o] = i._granularity), n
  }
  const L = t.Ellipsoid.clone(t.Ellipsoid.UNIT_SPHERE),
    T = { polylinePositions: void 0, shapePositions: void 0, ellipsoid: L, height: void 0, cornerType: void 0, granularity: void 0 }
  C.unpack = function (i, n, o) {
    let l
    n = e.defaultValue(n, 0)
    let r = i[n++]
    const s = new Array(r)
    for (l = 0; l < r; ++l, n += t.Cartesian3.packedLength) s[l] = t.Cartesian3.unpack(i, n)
    r = i[n++]
    const p = new Array(r)
    for (l = 0; l < r; ++l, n += a.Cartesian2.packedLength) p[l] = a.Cartesian2.unpack(i, n)
    const c = t.Ellipsoid.unpack(i, n, L)
    n += t.Ellipsoid.packedLength
    const d = i[n++],
      u = i[n]
    return e.defined(o)
      ? ((o._positions = s), (o._shape = p), (o._ellipsoid = t.Ellipsoid.clone(c, o._ellipsoid)), (o._cornerType = d), (o._granularity = u), o)
      : ((T.polylinePositions = s), (T.shapePositions = p), (T.cornerType = d), (T.granularity = u), new C(T))
  }
  const D = new n.BoundingRectangle()
  return (
    (C.createGeometry = function (e) {
      const a = e._positions,
        d = i.arrayRemoveDuplicates(a, t.Cartesian3.equalsEpsilon)
      let y = e._shape
      if (((y = r.PolylineVolumeGeometryLibrary.removeDuplicatesFromShape(y)), d.length < 2 || y.length < 3)) return
      u.PolygonPipeline.computeWindingOrder2D(y) === u.WindingOrder.CLOCKWISE && y.reverse()
      const f = n.BoundingRectangle.fromPoints(y, D)
      return (function (e, t) {
        const i = new p.GeometryAttributes()
        i.position = new s.GeometryAttribute({ componentDatatype: l.ComponentDatatype.DOUBLE, componentsPerAttribute: 3, values: e })
        const n = t.length,
          a = i.position.values.length / 3,
          r = e.length / 3 / n,
          d = c.IndexDatatype.createTypedArray(a, 2 * n * (r + 1))
        let u,
          y,
          f = 0
        u = 0
        let g = u * n
        for (y = 0; y < n - 1; y++) (d[f++] = y + g), (d[f++] = y + g + 1)
        for (d[f++] = n - 1 + g, d[f++] = g, u = r - 1, g = u * n, y = 0; y < n - 1; y++) (d[f++] = y + g), (d[f++] = y + g + 1)
        for (d[f++] = n - 1 + g, d[f++] = g, u = 0; u < r - 1; u++) {
          const e = n * u,
            t = e + n
          for (y = 0; y < n; y++) (d[f++] = y + e), (d[f++] = y + t)
        }
        return new s.Geometry({
          attributes: i,
          indices: c.IndexDatatype.createTypedArray(a, d),
          boundingSphere: o.BoundingSphere.fromVertices(e),
          primitiveType: s.PrimitiveType.LINES
        })
      })(r.PolylineVolumeGeometryLibrary.computePositions(d, y, f, e, !1), y)
    }),
    function (i, n) {
      return e.defined(n) && (i = C.unpack(i, n)), (i._ellipsoid = t.Ellipsoid.clone(i._ellipsoid)), C.createGeometry(i)
    }
  )
})
